<!DOCTYPE html>
<html lang="en">
    <head>
        {include file="public/header"}
        <script type="text/javascript">

        </script>
    </head>
    <body>
        <div class="wrapper">
            {include file="public/nav"}
            <div id="page-wrapper">
	            <div class="col-lg-12">
	                <h1 class="page-header">添加题目</h1>
	            </div>
                <div class="col-lg-3">试卷</div>
                <div class="col-lg-9">
                    <form id="form" class="form  form-horizontal" role="form" action="insert" method="post">
                        <input type="hidden" name="pid" value="{$pid}">
                        <div class="choice" id="choice">
                        </div>
                    </form>
                    <button class="btn btn-primary" id="submit">确定</button>

                </div>
            </div>
        </div>
        <div class="modal fade" tabindex="-1" role="dialog" id="modal">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">提示：</h4>
                    </div>
                    <div class="modal-body">
                        
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">确定</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->        
        {include file="public/javascript"}
        <script type="text/javascript">
         var form_input_group = '';
         ($.ajax({
             url : '_choice.html',
             /*              data : {id:app.id}, */
             dataType : 'html',
             success : function(html){
                 form_input_group = html;
                 $("#choice").html(html);
             }
         }));
         ($("#submit").on('click',function(){
             $.ajax({
                 url : 'insertquestion.html?',
                 type : "post",
                 data : $("#form").serialize(),
                 dataType : 'html',
                 success : function(res){
                     _res = JSON.parse(res);
                     if(_res.error == 0 ){
                         modal = $("#modal");
                         modal.find('.modal-body').html('添加成功');
                         modal.modal('show');
                         modal.modal('show').on('hide.bs.modal',function(){
                             $("#choice").html(form_input_group);
                         });
                     }else{
                         modal = $("#modal");
                         modal.find('.modal-body').html('添加失败');
                         modal.modal('show');
                     }
                 },
                 error : function(){
                     modal = $("#modal");
                     modal.find('.modal-body').html('添加失败');
                     modal.modal('show');
                 }
                 
             });
         }));
        </script>
    </body>
</html>
